use CIS2018_submission.dta
// Run this: Controls
global control_detrend edu age age2 married urban_hukou relative_income urban male tieabroad han partymember nodevice children_under6 

/* Table 2. Impact of 2018 Vaccine Crisis, OLS */
eststo clear
set more off
local vlist trustcentralgov trustcitygov
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'

eststo m`i': reghdfe `dv' log_exp_norm  $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
}
esttab m* ///
 using infogov.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm)   varlabel( _cons "Constant"  log_exp_norm "Salience" ) ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City", pattern(1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. For respondents surveyed from day 1 to day 38.") replace

//Table 2. Impact of 2018 Vaccine Crisis, 2SLS Estimations
//First Stage
eststo clear
set more off
eststo m1:   reg log_exp_norm days $control_detrend if purge_after == 0, robust
estadd local cov "Yes", replace
esttab m* ///
 using ivestimation_A.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons days)   varlabel( _cons "Constant"  days "Days from crisis") ///
eqlabel(none) nomtitles mgroups("Salience" , pattern(1) ) ///
stats(cov N r2, labels("Demographics" "Observations" "R-squared") fmt(0 0 3)) note("Start of survey to Aug 16 rectification.") replace

//Second Stage
eststo clear
set more off
local vlist trustcentralgov trustcitygov infopoltv 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=3{
eststo m`i':  ivreghdfe `dv' (log_exp_norm = days) $control_detrend if purge_after == 0, robust
estadd local cov "Yes", replace
 }
}
esttab m* ///
 using ivestimation_B.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm)   varlabel( _cons "Constant"  log_exp_norm "Salience") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Watch TV" , pattern(1 1 1) ) ///
stats(cov N r2, labels("Demographics"  "Observations" "R-squared") fmt(0 0 3)) note("Start of survey to Aug 16 rectification.") replace

/* Table 3. Heterogenous Effects of Government Correction */
eststo clear
set more off
local vlist trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'

eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm $control_detrend if dif > 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"

}
esttab m* ///
 using rectify_non_2016.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City", pattern(1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Excludes respondents surveyed on and before 21 July. ") replace

//Figure 5. Marginal Effects of Government Correction on Trust in the Center
interflex trustcentralgov purge_after log_exp_norm $control_detrend dmuid* ddate* if dif > 0 & affected_mu == 0, type(binning) cl(muid) cut(2.3 3.35) xlab("Salience, No Inside Info" ) dlab("Correction") ylab("Trust in Center")
 graph save marginal_non2016,replace
interflex trustcentralgov purge_after log_exp_norm $control_detrend dmuid* ddate* if dif > 0 & affected_mu == 1, type(binning) cl(muid) cut(2 3.2) xlab("Salience, Insider") dlab("Correction") ylab("Trust in Center")
 graph save marginal_2016, replace 
 graph combine "marginal_non2016" "marginal_2016" , ysize(3) xsize(6)

// Appendix 5. Before-and-After Estimations
eststo clear
set more off
local vlist trustcentralgov trustcitygov infopoltv
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'

eststo m`i': reghdfe `dv' vaccine_after  $control_detrend if purge_after == 0, ab(muid) cluster(muid)
estadd local fe "Yes"
}
esttab m* ///
 using after_crisis.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons vaccine_after)   varlabel( _cons "Constant"  vaccine_after "After crisis" ) ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Watch TV", pattern(1 1 1) ) ///
stats(fe fe  N r2, labels("City FE"  "Demographics"  "Observations" "R-squared") fmt(0 0 0 3)) note("Standard errors clustered around cities. For respondents surveyed from day 1 to day 38") replace

/* Appendix 8: Summary Statistics */
fsum edu age married children_under6 urban_hukou relative_income urban male tieabroad han partymember nodevice log_exp_norm affected_mu purge_after, u 
fsum trustcentralgov  trustcitygov infopoltv, u

/*  Appendix 9. Impact of 2018 Vaccine Crisis, 
OLS Estimations with City Covariates and salience not logged */
gen log_pop = log(年末户籍人口_万人_全市)
gen log_gdppc = log(人均地区生产总值_元_全市)
gen log_revpc = log(地方一般公共预算收入_万元_全市/年末户籍人口_万人_全市)
gen log_spdpc = log(地方一般公共预算支出_万元_全市/年末户籍人口_万人_全市)
gen purge_exp_norm_l = purge_after*exp_norm
drop exp_affected
gen exp_affected = exp_norm*affected_mu
gen purge_exp_affected = purge_after*affected_mu*exp_norm
global city_control log_pop log_gdppc log_revpc log_spdpc 第一产业占地区生产总值的比重_全市 第二产业占地区生产总值的比重_全市

eststo clear
set more off
local vlist trustcentralgov trustcitygov
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'

eststo m`i'_1: reghdfe `dv' exp_norm $control_detrend if purge_after == 0, ab(provid) cluster(muid)
estadd local fe "No"
estadd local de "No"
estadd local ce "No"
estadd local ie "Yes"

eststo m`i'_2: reghdfe `dv' exp_norm $control_detrend $city_control if purge_after == 0, ab(provid) cluster(muid)
estadd local fe "No"
estadd local de "No"
estadd local ce "Yes"
estadd local ie "Yes"

eststo m`i'_3: reghdfe `dv' exp_norm $control_detrend $city_control if purge_after == 0, ab(date provid) cluster(muid)
estadd local fe "No"
estadd local de "Yes"
estadd local ce "Yes"
estadd local ie "Yes"

}
esttab m* ///
 using infogov_nofe.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons exp_norm)   varlabel( _cons "Constant"  exp_norm "Salience" ) ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust Central" "Trust Central" "Trust City" "Trust City" "Trust City", pattern(1 1 1 1 1 1) ) ///
stats(fe de ce ie N r2, labels("City FE"  "Date FE" "City Covariates" "Demographics" "Observations" "R-squared") fmt(0 0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. City covariates include log(population), log(GDP per capita), log(fiscal spending/capita), log(fiscal revenue/capita), province, primary sector share, secondary sector share.") replace


/* Appendix 10. Balance Tables */
* Table A.10.1 Respondents in Cities Impacted by 2016 Vaccine Crisis vs. Other Respondents

local vlist edu age married children_under6 urban_hukou relative_income urban male tieabroad han partymember nodevice
local i = 1
foreach var in `vlist' {
    reg `var' affected_mu, robust
    outreg, keep(affected_mu)  rtitle("`: var label `var''") stats(b) ///
        noautosumm store(row`i')  starlevels(5 1) starloc(1)
    outreg, replay(diff) append(row`i') ctitles("",Difference ) ///
        store(diff) note("")
    local ++i
}
outreg, replay(diff)

* Table making
local count: word count $control_detrend
mat sumstat = J(`count',6,.)

local i = 1
foreach var in `vlist' {
    quietly: summarize `var' if affected_mu==0
    mat sumstat[`i',1] = r(N)
    mat sumstat[`i',2] = r(mean)
    mat sumstat[`i',3] = r(sd)
    quietly: summarize `var' if affected_mu==1
    mat sumstat[`i',4] = r(N)
    mat sumstat[`i',5] = r(mean)
    mat sumstat[`i',6] = r(sd)
    local i = `i' + 1
}
frmttable, statmat(sumstat) store(sumstat) sfmt(g,f,f,g,f,f)

/* Table A.10.2. Respondents in Cities Impacted by 2016 Vaccine Crisis vs. Other Respondents,
Before and During Crisis and After Correction */
gen before_crisis = (dif < 0)
gen in_crisis = (dif >= 0 & purge_after == 0)
gen after_correct = (purge_after == 1)

gen groups = 1 if affected_mu == 1 & before_crisis == 1
replace groups = 2 if affected_mu == 1 & in_crisis == 1
replace groups = 3 if affected_mu == 1 & after_correct == 1
replace groups = 4 if affected_mu == 0 & before_crisis == 1
replace groups = 5 if affected_mu == 0 & in_crisis == 1
replace groups = 6 if affected_mu == 0 & after_correct == 1

* ANOVA 
local count: word count $control_detrend
mat sumstat = J(`count',2,.) // Initialize matrix with 1 column for p-values
local i = 1
local vlist edu age married children_under6 urban_hukou relative_income urban male tieabroad han partymember nodevice
foreach var in `vlist' {
    anova `var' groups if affected_mu==0
    local pModel = Ftail(e(df_m),e(df_r),e(F)) // Calculate p-value inside the loop
    display "Model p = " `pModel'
    mat sumstat[`i',1] = `pModel' // Update matrix with p-value
    anova `var' groups if affected_mu==1
    local pModel = Ftail(e(df_m),e(df_r),e(F)) // Calculate p-value inside the loop
    display "Model p = " `pModel'
    mat sumstat[`i',2] = `pModel' // Update matrix with p-value
    local i = `i' + 1
}
frmttable, statmat(sumstat) store(sumstat)

* Table making
local count: word count $control_detrend
mat sumstat = J(`count',12,.)
local i = 1
local vlist edu age married children_under6 urban_hukou relative_income urban male tieabroad han partymember nodevice
foreach var in `vlist' {
    quietly: summarize `var' if groups==1
    mat sumstat[`i',1] = r(mean)
    mat sumstat[`i',2] = r(sd)
    quietly: summarize `var' if groups==2
    mat sumstat[`i',3] = r(mean)
    mat sumstat[`i',4] = r(sd)
    quietly: summarize `var' if groups==3
    mat sumstat[`i',5] = r(mean)
    mat sumstat[`i',6] = r(sd)
    quietly: summarize `var' if groups==4
    mat sumstat[`i',7] = r(mean)
    mat sumstat[`i',8] = r(sd)
    quietly: summarize `var' if groups==5
    mat sumstat[`i',9] = r(mean)
    mat sumstat[`i',10] = r(sd)
    quietly: summarize `var' if groups==6
    mat sumstat[`i',11] = r(mean)
    mat sumstat[`i',12] = r(sd)
    local i = `i' + 1
}
frmttable, statmat(sumstat) store(sumstat) 

/* Appendix 11. Correction Analysis with Triple Interaction */
gen purge_exp_norm_affected = exp_norm_affected * purge_after
eststo clear
set more off
local vlist trustcentralgov trustcitygov infopoltv 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=3{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm purge_affected exp_norm_affected purge_exp_norm_affected $control_detrend if dif > 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
}
esttab m* ///
 using rectify_triple.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm purge_affected exp_norm_affected purge_exp_norm_affected)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification" ///
  purge_affected "Affected Cities*After Rectification" exp_norm_affected "Salience*Affected Cities" purge_exp_norm_affected "Salience*Affected Cities*After Rectification") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Watch TV" , pattern(1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of crisis to end of survey. ") replace

// Sum of Coefficients
//Trust Center
reg trustcentralgov log_exp_norm purge_exp_norm purge_affected exp_norm_affected purge_exp_norm_affected $control_detrend ddate* dmuid* if dif > 0, cluster(muid)
matrix b = e(b)
// (1) Affected + After Purge (zero, insignificantly positive)
test log_exp_norm + purge_exp_norm + exp_norm_affected + purge_exp_norm_affected = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] + b[1, "exp_norm_affected"] + b[1, "purge_exp_norm_affected"]
 display "Sum of coefficients: " sum_coeff
// (2) Affected + Before Purge (zero, insignificantly positive, more positive than (1))
test log_exp_norm + exp_norm_affected  = 0
scalar sum_coeff = b[1, "log_exp_norm"] +  b[1, "exp_norm_affected"] 
 display "Sum of coefficients: " sum_coeff
// (3) Non-Affected + After Purge (negative)
test log_exp_norm + purge_exp_norm  = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] 
 display "Sum of coefficients: " sum_coeff
// (4) Non-Affected + Before Purge (negative, less negative than (3))
test log_exp_norm 
display b[1, "log_exp_norm"]

//Trust City
reg trustcitygov log_exp_norm purge_exp_norm purge_affected exp_norm_affected purge_exp_norm_affected $control_detrend ddate* dmuid* if dif > 0, cluster(muid)
matrix b = e(b)
// (1) Affected + After Purge (zero, insignificantly negative)
test log_exp_norm + purge_exp_norm + exp_norm_affected + purge_exp_norm_affected = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] + b[1, "exp_norm_affected"] + b[1, "purge_exp_norm_affected"]
 display "Sum of coefficients: " sum_coeff
// (2) Affected + Before Purge (zero, insignificantly positive, more positive than (1))
test log_exp_norm + exp_norm_affected  = 0
scalar sum_coeff = b[1, "log_exp_norm"] +  b[1, "exp_norm_affected"] 
 display "Sum of coefficients: " sum_coeff
// (3) Non-Affected + After Purge (zero, insignificantly positive)
test log_exp_norm + purge_exp_norm  = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] 
 display "Sum of coefficients: " sum_coeff
// (4) Non-Affected + Before Purge (negative)
test log_exp_norm 
display b[1, "log_exp_norm"]

// Watch TV News
reg infopoltv log_exp_norm purge_exp_norm purge_affected exp_norm_affected purge_exp_norm_affected $control_detrend ddate* dmuid* if dif > 0, cluster(muid)
matrix b = e(b)
// (1) Affected + After Purge (negative)
test log_exp_norm + purge_exp_norm + exp_norm_affected + purge_exp_norm_affected = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] + b[1, "exp_norm_affected"] + b[1, "purge_exp_norm_affected"]
 display "Sum of coefficients: " sum_coeff
// (2) Affected + Before Purge (zero, insignificantly negative, more positive than (1))
test log_exp_norm + exp_norm_affected  = 0
scalar sum_coeff = b[1, "log_exp_norm"] +  b[1, "exp_norm_affected"] 
 display "Sum of coefficients: " sum_coeff
// (3) Non-Affected + After Purge (positive)
test log_exp_norm + purge_exp_norm  = 0
scalar sum_coeff = b[1, "log_exp_norm"] + b[1, "purge_exp_norm"] 
 display "Sum of coefficients: " sum_coeff
// (4) Non-Affected + Before Purge (negative)
test log_exp_norm 
display b[1, "log_exp_norm"]


/* Appendix 13. Seemingly Unrelated Estimation with Wald Tests */
quiet reg trustcentralgov log_exp_norm purge_exp_norm $control_detrend ddate* dmuid* if dif > 0 & affected_mu==0
est sto first
quiet reg trustcentralgov log_exp_norm purge_exp_norm $control_detrend ddate* dmuid* if dif > 0 & affected_mu==1
est sto second
quiet suest first second, cluster(muid)
test [first_mean]purge_exp_norm = [second_mean]purge_exp_norm

quiet reg trustcitygov log_exp_norm purge_exp_norm $control_detrend ddate* dmuid* if dif > 0 & affected_mu==0
est sto first
quiet reg trustcitygov log_exp_norm purge_exp_norm $control_detrend ddate* dmuid* if dif > 0 & affected_mu==1
est sto second
quiet suest first second, cluster(muid)
test [first_mean]purge_exp_norm = [second_mean]purge_exp_norm


/* Appendix 14. Coarsened Exact Matching (CEM), including TV Viewing */
//Table A.13.1. Table 2 CEM, including TV Viewing
cem edu(#9) age(#5) married(#2) urban_hukou(#2) urban(#2) male(#2) relative_income(#4) tieabroad(#2) han(#2) partymember(#2) nodevice(#2) children_under6(#2), show treat(vaccine_after)
eststo clear
set more off
local vlist trustcentralgov trustcitygov infopoltv
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'

eststo m`i': reghdfe `dv' log_exp_norm  $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
}
esttab m* ///
 using cem_table1.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm)   varlabel( _cons "Constant"  log_exp_norm "Salience" ) ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Watch TV", pattern(1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace

//Table A.13.2. Table 3 CEM, including TV Viewing
cem edu(#9) age(#5) married(#2) urban_hukou(#2) urban(#2) male(#2) relative_income(#4) tieabroad(#2) han(#2) partymember(#2) nodevice(#2) children_under6(#2), show treat(purge_after)
eststo clear
set more off
local vlist trustcentralgov trustcitygov infopoltv trustcentralgov trustcitygov infopoltv 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=3{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm $control_detrend [w=cem_weights] if dif > 0 & affected_mu==0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
  if  `i'>3{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm $control_detrend [w=cem_weights] if dif > 0 & affected_mu==1, ab(date muid)  cluster(muid)
estadd local fe "Yes"
  }
}
esttab m* ///
 using rectify.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Watch TV" "Trust Central" "Trust City" "Watch TV" , pattern(1 1 1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of crisis to end of survey. ") replace

/* Appendix 15. Impact of 2018 Vaccine Crisis, OLS Estimation, 
Salience Measured as Square Root of Relative Change in Search */
gen exp_norm_sqr = exp_norm^0.5
gen purge_exp_norm_sqr = purge_after*exp_norm_sqr

eststo clear
set more off
local vlist trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
eststo m`i': reghdfe `dv' exp_norm_sqr $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
}
esttab m* ///
 using sqr_table2.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons exp_norm_sqr)   varlabel( _cons "Constant"  exp_norm_sqr "Salience" ) ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City", pattern(1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Slience is square root of relative change in search. Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace

/* Appendix 16. Heterogenous Effects of Government Correction, OLS Estimation,
Salience Measured as Square Root of Search Change */
eststo clear
set more off
local vlist trustcentralgov trustcitygov trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=2{
eststo m`i': reghdfe `dv' exp_norm_sqr purge_exp_norm_sqr $control_detrend  if dif > 0 & affected_mu==0, ab(muid date) cluster(muid)
estadd local fe "Yes"
 }
  if  `i'>2{
eststo m`i': reghdfe `dv' exp_norm_sqr purge_exp_norm_sqr $control_detrend  if dif > 0 & affected_mu==1, ab(muid date)  cluster(muid)
estadd local fe "Yes"
  }
}
esttab m* ///
 using sqr_table3.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons exp_norm_sqr purge_exp_norm_sqr)   varlabel( _cons "Constant"  exp_norm_sqr "Salience"  purge_exp_norm_sqr "Salience*After Rectification") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Trust Central" "Trust City" , pattern(1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared") fmt(0 0 0 0 3)) note("Slience is square root of relative change in search. Standard errors clustered around cities. Start of crisis to end of survey. ") replace

/* Appendix 18. Ruling Out Alternative Mechanisms */
// Control Mechanisms
gen health_con = K6
replace health_con = . if health_con == 9
label var health_con "Health Condition"
gen exp_health = health_con*log_exp_norm
gen health_hot = B1H

// Table A.15.1. Alternative Mechanism: Health Condition
eststo clear
set more off
local vlist trustcentralgov trustcitygov trustcentralgov trustcitygov trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=2{
eststo m`i': reghdfe `dv' log_exp_norm health_con $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
  if  `i'==3|`i'==4{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm health_con $control_detrend if dif > 0 & affected_mu==0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
   if  `i'>=5{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm health_con $control_detrend if dif > 0 & affected_mu==1, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
}
esttab m* ///
 using trust_hc.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm health_con)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification" health_con "Health Condition") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Trust Central" "Trust City" "Trust Central" "Trust City", pattern(1 1 1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace

// Table A.15.2. Alternative Mechanism: Health Topic
eststo clear
set more off
local vlist trustcentralgov trustcitygov trustcentralgov trustcitygov trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=2{
eststo m`i': reghdfe `dv' log_exp_norm health_hot $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
  if  `i'==3|`i'==4{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm health_hot $control_detrend if dif > 0 & affected_mu==0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
   if  `i'>=5{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm health_hot $control_detrend if dif > 0 & affected_mu==1, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
}
esttab m* ///
 using trust_ht.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm health_hot)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification" health_hot "Health Topic") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Trust Central" "Trust City" "Trust Central" "Trust City", pattern(1 1 1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace

// Table A.15.3. Alternative Mechanism: Political Interest
eststo clear
set more off
local vlist trustcentralgov trustcitygov trustcentralgov trustcitygov trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=2{
eststo m`i': reghdfe `dv' log_exp_norm polint $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
  if  `i'==3|`i'==4{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm polint $control_detrend if dif > 0 & affected_mu==0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
   if  `i'>=5{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm polint $control_detrend if dif > 0 & affected_mu==1, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
}
esttab m* ///
 using trust_polint.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm polint)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification" polint "Political Interest") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Trust Central" "Trust City" "Trust Central" "Trust City", pattern(1 1 1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace


// Table A.15.5. Alternative Mechanism: Public Affairs Topic
eststo clear
set more off
local vlist trustcentralgov trustcitygov trustcentralgov trustcitygov trustcentralgov trustcitygov 
local wd=wordcount("`vlist'")
forv i=1/`wd'{
local dv: word `i' of `vlist'
 if  `i'<=2{
eststo m`i': reghdfe `dv' log_exp_norm topicpub $control_detrend if purge_after == 0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
  if  `i'==3|`i'==4{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm topicpub $control_detrend if dif > 0 & affected_mu==0, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
   if  `i'>=5{
eststo m`i': reghdfe `dv' log_exp_norm purge_exp_norm topicpub $control_detrend if dif > 0 & affected_mu==1, ab(date muid)  cluster(muid)
estadd local fe "Yes"
 }
}
esttab m* ///
 using trust_ct.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep (_cons log_exp_norm purge_exp_norm topicpub)   varlabel( _cons "Constant"  log_exp_norm "Salience" purge_exp_norm "Salience*After Rectification" topicpub "Public Affairs") ///
eqlabel(none) nomtitles mgroups("Trust Central" "Trust City" "Trust Central" "Trust City" "Trust Central" "Trust City", pattern(1 1 1 1 1 1) ) ///
stats(fe fe fe  N r2, labels("City FE"  "Date FE"  "Demographics"  "Observations" "R-squared" "R-squared (Within)") fmt(0 0 0 0 3)) note("Standard errors clustered around cities. Start of survey to Aug 16 purge. ") replace

/*  Appendix 17. Models with Crisis Salience Levels in Four Periods, 
“Vaccine” as Dependent Variable */
import excel "2016VaccineCrisis.xlsx", sheet("Sheet1") firstrow clear
label var affected_mu "affected cities in 2016 crisis"
label define affected_mu 0 "New failure" 1 "Familiar failure", replace
label values affected_mu affected

egen rank_2016_pre = rank(bi_2016_pre)
egen rank_2016 = rank(bi_2016)
egen rank_2016_sd = rank(bi_2016_shandong)
egen rank_2018_pre = rank(bi_pre)
//egen rank_2018 = rank(BI_average)
egen rank_2018_hi = rank(BI_height)

reshape long rank_, i(muid) j(year) string
gen period = (year == "2016_pre")
replace period = 2 if year == "2016_sd"
replace period = 3 if year == "2018_pre"
replace period = 4 if year == "2018_hi"
replace period = . if year == "2016"|year =="2018"

// Table making
eststo clear
set more off
eststo m1: reghdfe rank_ affected_mu##period, noab cluster(muid)
estadd local fe "Yes"
esttab m1 ///
 using salience_affected.doc, rtf se(3) b(3)  r2(3)label star(* 0.05) ///
keep(_cons 1.affected_mu 1.affected_mu#2.period 1.affected_mu#3.period 1.affected_mu#4.period) ///
varlabel(_cons "Constant" 1.affected_mu "2016 City" 1.affected_mu#2.period "2016 City*2016-Crisis-Height" 1.affected_mu#3.period "2016 City*Pre-2018-Crisis" 1.affected_mu#4.period "2016 City*2018-Crisis-Height") ///
eqlabel(none) nomtitles mgroups("Crisis Salience Ranking" , pattern(1) ) ///
stats(fe N r2, labels("Period FE" "Observations" "R-squared") fmt(0 0 3)) ///
note("Standard errors clustered around cities. Dependent variable: salience level. All 63 cities surveyed included and all salience is for “vaccine.” Comparison group is pre-2016-crisis non-2016 insider cities. 2016-Crisis-Height denotes average salience from 17 March to 30 June 2016. Pre-2018-Crisis denotes 1-year average salience before 2018 crisis. 2018-Crisis-Height denotes the city's peak salience for July 2018.") replace
